home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / PowerPC / vbcc / machines / amigawos / libsrc / time / time.c < prev   
C/C++ Source or Header  |  1998-08-02  |  875b  |  42 lines

  1. /*
  2. ** vbcc-PowerOpen/WarpOS version of time.c
  3. **
  4. ** v0.1 06.03.97 phx
  5. */
  6.  
  7. #include <time.h>
  8. #include <dos/dos.h>
  9. #include <powerpc/powerpc.h>
  10. #include <clib/powerpc_protos.h>
  11.  
  12. extern long __gmtoffset;
  13. extern ULONG DOSBase;
  14.  
  15.  
  16. time_t time(time_t *tloc)
  17. {
  18.   struct DateStamp t;
  19.   time_t ti;
  20.   struct PPCArgs pa;
  21.  
  22.   pa.PP_Code = (APTR)DOSBase;
  23.   pa.PP_Offset = -192;  /* _LVODateStamp */
  24.   pa.PP_Flags = pa.PP_StackSize = 0;
  25.   pa.PP_Stack = NULL;
  26.   pa.PP_Regs[PPREG_D1] = (ULONG)&t;
  27.   pa.PP_Regs[PPREG_A6] = (ULONG)DOSBase;
  28.   Run68k(&pa);  /* Get timestamp */
  29.   ti=((t.ds_Days+2922)*1440+t.ds_Minute+__gmtoffset)*60+
  30.       t.ds_Tick/TICKS_PER_SECOND;
  31.   if(tloc!=NULL)
  32.     *tloc=ti;
  33.   return ti;
  34. }
  35.  
  36. /*
  37.  * 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6
  38. normal)
  39.  * 1440 is the number of minutes per day
  40.  *   60 is the number of seconds per minute
  41.  */ 
  42.